<?php 
use com\soka as soka;
class Pages_Mdl extends Soka\SokaModel
{
    public function get_menu_item($user_access) { 
        $menu= array();     
        //$sql =  "SELECT id, title, link, parent, access FROM pages  WHERE access = {$user_access} ORDER BY ordering, title ASC"; 
        $sql = "SELECT
        pg.id, pg.title, pg.link, pg.parent
        FROM    permisos per
        INNER JOIN pages pg ON per.page_id = pg.id
        WHERE   per.rol_id = {$user_access} ";

        $query = $this->_db->query($sql);
        while ($row = $query->fetch(\PDO::FETCH_ASSOC)){
            $menu['items'][$row['id']] = $row;
            $menu['parents'][$row['parent']][] = $row['id'];
        }
        return $menu;
    }
}